﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DHISInteroperability.Timeframe;

namespace DHISInteroperability.Tests
{
    [TestClass]
    public class PeriodTest
    {
        [TestMethod]
        public void Daily_Period_Format()
        {
            var period = new Period();
            period.StartDate = DateTime.Parse("2004-03-15");
            period.Format = PeriodFormat.DAILY;

            string sExpected = "20040315";
            string sActual = period.GetFormattedPeriod();

            Assert.AreEqual(sExpected, sActual, "Day - Period format failed to convert");
        }

        [TestMethod]
        public void Week_Period_Format()
        {
            var period = new Period();
            period.StartDate = DateTime.Parse("2004-03-15");
            period.Format = PeriodFormat.WEEKLY;

            string sExpected = "2004W12";
            string sActual = period.GetFormattedPeriod();

            Assert.AreEqual(sExpected, sActual, "Week - Period format failed to convert");
        }

        [TestMethod]
        public void Month_Period_Format()
        {
            var period = new Period();
            period.StartDate = DateTime.Parse("2004-03-15");
            period.Format = PeriodFormat.MONTHLY;

            string sExpected = "200403";
            string sActual = period.GetFormattedPeriod();

            Assert.AreEqual(sExpected, sActual, "Month - Period format failed to convert");
        }

        [TestMethod]
        public void Quarter_Period_Format()
        {
            var period = new Period();
            period.StartDate = DateTime.Parse("2004-03-15");
            period.Format = PeriodFormat.QUARTERLY;

            string sExpected = "2004Q1";
            string sActual = period.GetFormattedPeriod();

            Assert.AreEqual(sExpected, sActual, "Quarter - Period format failed to convert");
        }
    }
}
